package com.core.service.lucene;

import com.core.configuration.*;

import jeasy.analysis.MMAnalyzer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Lucene Parse 类
 * 
 * @author 刘威
 * 
 */
public class QueryParse {

	private static Log log = LogFactory.getLog(QueryParse.class);
	/**
	 * 参数分隔长度
	 */
	private static final int parseSize = Configuration.LUCENE_SIZE;
	/**
	 * 参数分隔符
	 */
	private static final String separator = ",";

	/**
	 * 分隔查询参数
	 * 
	 * @param query
	 * @return
	 */
	public static String[] parseQueryPhrase(String query) {
		String[] ret = null;
		try {
			if (query == null || query.equals("")) {
				return ret;
			}
			MMAnalyzer m = new MMAnalyzer(parseSize);
			String tmp = m.segment(query, separator);
			if (tmp != null && !tmp.equals("")) {
				ret = tmp.split(separator);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}
}
